import pygame
import json

class Config:
    def __init__(self):
        self.screen_width = 800
        self.screen_height = 600

        self.colors = {
            'white': (255, 255, 255),
            'blue': (0, 0, 255),
            'red': (255, 0, 0),
            'black': (0, 0, 0),
            'green': (0, 255, 0)
        }

        self.ball_radius = 10
        self.ball_MAX_SPEED = 15


        self.paddle_width = 100
        self.paddle_height = 20
        self.paddle_speed = 8
        self.fps = 60
        self.brick_rows = 5
        self.brick_cols = 10
        self.brick_width = 70
        self.brick_height = 20
        self.brick_padding = 5
        # 使用中文字体
        self.font_path = "fonts/msyh.ttc"  # 替换为你的字体文件路径
        self.countdown_font = pygame.font.Font(self.font_path, 74)
        self.countscore_font = pygame.font.Font(self.font_path, 36)
        self.high_score_file = "high_scores.json"

    def load_high_scores(self):
        try:
            with open(self.high_score_file, 'r') as f:
                return json.load(f)
        except:
            return {"high_scores": [-1]}

    def save_high_scores(self, scores):
        with open(self.high_score_file, 'w') as f:
            json.dump(scores, f)